import { BaseEntity, ColumnInfo, TableInfo } from '../BaseEntity';

/**
 * 用户实体类
 */
export class User extends BaseEntity {
  id?: number;
  username!: string;
  password!: string;
  nickname?: string;
  email?: string;
  avatar?: string;
  status?: number;
  createTime?: number;
  updateTime?: number;
  
  constructor(user?: Partial<User>) {
    super();
    if (user) {
      Object.assign(this, user);
    }
  }
  
  /**
   * 获取表信息
   */
  static getTableInfo(): TableInfo {
    return {
      name: 'user',
      primaryKey: 'id',
      columns: [
        {
          name: 'id',
          type: 'INTEGER',
          primaryKey: true,
          autoIncrement: true
        },
        {
          name: 'username',
          type: 'TEXT',
          notNull: true,
          unique: true
        },
        {
          name: 'password',
          type: 'TEXT',
          notNull: true
        },
        {
          name: 'nickname',
          type: 'TEXT'
        },
        {
          name: 'email',
          type: 'TEXT',
          unique: true
        },
        {
          name: 'avatar',
          type: 'TEXT'
        },
        {
          name: 'status',
          type: 'INTEGER',
          default: 1
        },
        {
          name: 'createTime',
          type: 'INTEGER',
          notNull: true,
          default: 'CURRENT_TIMESTAMP'
        },
        {
          name: 'updateTime',
          type: 'INTEGER',
          default: 'CURRENT_TIMESTAMP'
        }
      ]
    };
  }
} 